<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>收派时间管理</title>
		<!-- 导入jquery核心类库 -->
		<script type="text/javascript" src="../../js/jquery-1.8.3.js"></script>
		<!-- 导入easyui类库 -->
		<link rel="stylesheet" type="text/css" href="../../js/easyui/themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../js/easyui/themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../../js/easyui/ext/portal.css">
		<link rel="stylesheet" type="text/css" href="../../css/default.css">
		<script type="text/javascript" src="../../js/easyui/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../../js/easyui/ext/jquery.portal.js"></script>
		<script type="text/javascript" src="../../js/easyui/ext/jquery.cookie.js"></script>
		<script src="../../js/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
		<script type="text/javascript">
			$(function(){
				// 先将body隐藏，再显示，不会出现页面刷新效果
				$("body").css({visibility:"visible"});
				
				// 收派时间管理信息表格
				$('#grid').datagrid( {
					iconCls : 'icon-forward',
					fit : true,
					border : false,
					rownumbers : true,
					striped : true,
					pageList: [30,50,100],
					pagination : true,
					toolbar : toolbar,
					url : "../../taketime/taketime_pagequery.action",
					idField : 'id',
					columns : columns
				});
				//保存窗口保存操作
				$("#save").click(function () {
					if($("#save_taketime").form('validate')){
						$("#save_taketime").submit();
					}else{
						$.messager.alert("警告","信息不完整,无法保存!","warning");
					};
				});
			});	
			
			//工具栏
			var toolbar = [ {
				id : 'button-add',
				text : '增加',
				iconCls : 'icon-add',
				handler : function(){
					$("#addWindow").window('open');
				}
			}, {
				id : 'button-edit',
				text : '修改',
				iconCls : 'icon-edit',
				handler : function(){
					var sel = $("#grid").datagrid('getSelections');
					if (sel.length != 1) {
						$.messager.alert("警告","修改时只能且必须选择一条记录!","warning")
					} else{
						$("#save_taketime").form("load",sel[0]);
						$("#addWindow").window("open");
					}
				}
			},{
				id : 'button-delete',
				text : '删除',
				iconCls : 'icon-cancel',
				handler : function(){
					//获取选择的记录
					var sel = $("#grid").datagrid('getSelections');
					//判断是否选择
					if (sel.length == 0) {
						//没有选择弹出警告
						$.messager.alert("警告","请选择需要作废的记录!","warning")
					} else{
						$.messager.confirm('提示', '是否确认删除?', function(flag){
							if (flag) {
								var array = new Array();
								var ids = array.join(",");
								window.location.href="../../taketime/deltaketime.action?ids="+ids;
							}
						});
					}
				}
			} ,{
				id : 'button-delete',
				text : '作废',
				iconCls : 'icon-cancel',
				handler : function(){
					//获取选择的记录
					var sel = $("#grid").datagrid('getSelections');
					//判断是否选择
					if (sel.length == 0) {
						//没有选择弹出警告
						$.messager.alert("警告","请选择需要作废的记录!","warning")
					} else{
						//遍历选择吃的记录获取其id,保存至数组
						var array = new Array();
						$(sel).each(function(i,n){
							if(n.status != "1"){
								array.push(n.id);
							}
						});
						//将数组转成字符串
						var ids = array.join(",");
						window.location.href="../../taketime/canceltaketime.action?ids="+ids;
					};
				}
			},{
				id : 'button-restore',
				text : '还原',
				iconCls : 'icon-save',
				handler : function(){
					//获取选择的记录
					var sel = $("#grid").datagrid('getSelections');
					//判断是否选择
					if (sel.length == 0) {
						//没有选择弹出警告
						$.messager.alert("警告","请选择需要还原的记录!","warning")
					} else{
						//遍历选择吃的记录获取其id,保存至数组
						var array = new Array();
						$(sel).each(function(i,n){
							if(n.status == "1"){
								array.push(n.id);
							}
						});
						//将数组转成字符串
						var ids = array.join(",");
						window.location.href="../../taketime/restoretaketime.action?ids="+ids;
					};
				}
			}];
			
			// 定义列
			var columns = [ [ {
				field : 'id',
				checkbox : true,
			},{
				field : 'name',
				title : '时间名称',
				width : 120,
				align : 'center'
			}, {
				field : 'normalWorkTime',
				title : '平时上班时间',
				width : 120,
				align : 'center'
			}, {
				field : 'normalDutyTime',
				title : '平时休息时间',
				width : 120,
				align : 'center'
			}, {
				field : 'satWorkTime',
				title : '周六上班时间',
				width : 120,
				align : 'center'
			}, {
				field : 'satDutyTime',
				title : '周六休息时间',
				width : 120,
				align : 'center'
			}, {
				field : 'sunWorkTime',
				title : '周日上班时间',
				width : 120,
				align : 'center'
			}, {
				field : 'sunDutyTime',
				title : '周日休息时间',
				width : 120,
				align : 'center'
			}, {
				field : 'status',
				title : '状态',
				width : 120,
				align : 'center',
				formatter : function(data,row ,index){
							if(data == "1"){
								return "已作废";
							}else{
								return "正常使用";
							}
						}
			}, {
				field : 'company',
				title : '所属单位',
				width : 120,
				align : 'center'
			} , {
				field : 'operator',
				title : '操作人',
				width : 120,
				align : 'center'
			}, {
				field : 'operatingTime',
				title : '操作时间',
				width : 120,
				align : 'center'
			}, {
				field : 'operatingCompany',
				title : '操作单位',
				width : 120,
				align : 'center'
			} ] ];
		</script>
	</head>
	<body class="easyui-layout" style="visibility:hidden;">
		<div region="center" border="false">
			<table id="grid"></table>
		</div>
		<!-- 添加 修改分区 -->
		<div class="easyui-window" closed=true title="取派时间添加修改" id="addWindow" modal=true collapsible="false" minimizable="false" maximizable="false" style="width: 400px;top:20px;left:200px">
			<div style="height:31px;overflow:hidden;" split="false" border="false">
				<div class="datagrid-toolbar">
					<a id="save" icon="icon-save" href="#" class="easyui-linkbutton" plain="true">保存</a>
				</div>
			</div>

			<div style="overflow:auto;padding:5px;" border="false">
				<form id="save_taketime" action="../../taketime/taketime_save.action" method="post" >
					<table class="table-edit" width="80%" align="center">
						<tr class="title">
							<td colspan="2">收派时间信息</td>
						</tr>
						<tr>
							<td>收派时间名称</td>
							<td>
								<input type="text" name="name" class="easyui-validatebox" required="true" />
								<input type="hidden" name="id" />
							</td>
						</tr>
						<tr>
							<td>正常上班时间</td>
							<td>
								<input type="text" name="normalWorkTime" class="easyui-validatebox" required="true" />
							</td>
						</tr>
						<tr>
							<td>正常下班时间</td>
							<td>
								<input name="normalDutyTime" class="easyui-validatebox" required="true"/>
							</td>
						</tr>
						<tr>
							<td>周六上班时间</td>
							<td>
								<input type="text" name="satWorkTime" class="easyui-validatebox" required="true" />
							</td>
						</tr>
						<tr>
							<td>周六下班时间</td>
							<td>
								<input name="satDutyTime" class="easyui-validatebox" required="true"/>
							</td>
						</tr>
						<tr>
							<td>周日上班时间</td>
							<td>
								<input type="text" name="sunWorkTime" class="easyui-validatebox" required="true" />
							</td>
						</tr>
						<tr>
							<td>周日下班时间</td>
							<td>
								<input name="sunDutyTime" class="easyui-validatebox" required="true"/>
							</td>
						</tr>
					</table>
				</form>
			</div>
		</div>
	</body>
</html>
